home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1995 June: Reference Library / Dev.CD Jun 95 / Dev.CD Jun 95.toast / What's New? / Tool Chest / Interfaces / UniversalInterfaces 2.0 / PInterfaces / SoundInput.p < prev    next >
Encoding:
Text File  |  1995-04-18  |  9.8 KB  |  281 lines  |  [TEXT/MPS ]

  1. {
  2.      File:        SoundInput.p
  3.  
  4.      Contains:    Sound Input Interfaces.
  5.  
  6.      Version:    Technology:    System 7.5
  7.                  Package:    Universal Interfaces 2.0 in “MPW Latest” on ETO #17
  8.  
  9.      Copyright:    © 1984-1995 by Apple Computer, Inc.
  10.                  All rights reserved.
  11.  
  12.      Bugs?:        If you find a problem with this file, use the Apple Bug Reporter
  13.                  stack.  Include the file and version information (from above)
  14.                  in the problem description and send to:
  15.                      Internet:    apple.bugs@applelink.apple.com
  16.                      AppleLink:    APPLE.BUGS
  17.  
  18. }
  19.  
  20. {$IFC UNDEFINED UsingIncludes}
  21. {$SETC UsingIncludes := 0}
  22. {$ENDC}
  23.  
  24. {$IFC NOT UsingIncludes}
  25.  UNIT SoundInput;
  26.  INTERFACE
  27. {$ENDC}
  28.  
  29. {$IFC UNDEFINED __SOUNDINPUT__}
  30. {$SETC __SOUNDINPUT__ := 1}
  31.  
  32. {$I+}
  33. {$SETC SoundInputIncludes := UsingIncludes}
  34. {$SETC UsingIncludes := 1}
  35.  
  36.  
  37. {$IFC UNDEFINED __TYPES__}
  38. {$I Types.p}
  39. {$ENDC}
  40. {    ConditionalMacros.p                                            }
  41.  
  42. {$IFC UNDEFINED __APPLEEVENTS__}
  43. {$I AppleEvents.p}
  44. {$ENDC}
  45. {    Errors.p                                                    }
  46. {    Memory.p                                                    }
  47. {        MixedMode.p                                                }
  48. {    OSUtils.p                                                    }
  49. {    Events.p                                                    }
  50. {        Quickdraw.p                                                }
  51. {            QuickdrawText.p                                        }
  52. {    EPPC.p                                                        }
  53. {        AppleTalk.p                                                }
  54. {        Files.p                                                    }
  55. {        PPCToolbox.p                                            }
  56. {        Processes.p                                                }
  57. {    Notification.p                                                }
  58.  
  59. {$IFC UNDEFINED __WINDOWS__}
  60. {$I Windows.p}
  61. {$ENDC}
  62. {    Controls.p                                                    }
  63. {        Menus.p                                                    }
  64.  
  65. {$IFC UNDEFINED __DIALOGS__}
  66. {$I Dialogs.p}
  67. {$ENDC}
  68. {    TextEdit.p                                                    }
  69.  
  70. {$IFC UNDEFINED __FILES__}
  71. {$I Files.p}
  72. {$ENDC}
  73.  
  74. {$IFC UNDEFINED __SOUND__}
  75. {$I Sound.p}
  76. {$ENDC}
  77.  
  78. {$PUSH}
  79. {$ALIGN MAC68K}
  80. {$LibExport+}
  81.  
  82. CONST
  83.     siDeviceIsConnected            = 1;                            {input device is connected and ready for input}
  84.     siDeviceNotConnected        = 0;                            {input device is not connected}
  85.     siDontKnowIfConnected        = -1;                            {can't tell if input device is connected}
  86.     siReadPermission            = 0;                            {permission passed to SPBOpenDevice}
  87.     siWritePermission            = 1;                            {permission passed to SPBOpenDevice}
  88.  
  89. {Info Selectors for Sound Input Drivers}
  90.     siActiveChannels            = 'chac';                        {active channels}
  91.     siActiveLevels                = 'lmac';                        {active meter levels}
  92.     siAGCOnOff                    = 'agc ';                        {automatic gain control state}
  93.     siAsync                        = 'asyn';                        {asynchronous capability}
  94.     siChannelAvailable            = 'chav';                        {number of channels available}
  95.     siCompressionAvailable        = 'cmav';                        {compression types available}
  96.     siCompressionFactor            = 'cmfa';                        {current compression factor}
  97.     siCompressionHeader            = 'cmhd';                        {return compression header}
  98.     siCompressionNames            = 'cnam';                        {compression type names available}
  99.     siCompressionType            = 'comp';                        {current compression type}
  100.     siContinuous                = 'cont';                        {continous recording}
  101.     siDeviceBufferInfo            = 'dbin';                        {size of interrupt buffer}
  102.     siDeviceConnected            = 'dcon';                        {input device connection status}
  103.     siDeviceIcon                = 'icon';                        {input device icon}
  104.     siDeviceName                = 'name';                        {input device name}
  105.     siHardwareBusy                = 'hwbs';                        {sound hardware is in use}
  106.     siInputGain                    = 'gain';                        {input gain}
  107.     siInputSource                = 'sour';                        {input source selector}
  108.     siInputSourceNames            = 'snam';                        {input source names}
  109.     siLevelMeterOnOff            = 'lmet';                        {level meter state}
  110.     siNumberChannels            = 'chan';                        {current number of channels}
  111.     siOptionsDialog                = 'optd';                        {display options dialog}
  112.     siPlayThruOnOff                = 'plth';                        {playthrough state}
  113.     siRecordingQuality            = 'qual';                        {recording quality}
  114.     siSampleRate                = 'srat';                        {current sample rate}
  115.     siSampleRateAvailable        = 'srav';                        {sample rates available}
  116.     siSampleSize                = 'ssiz';                        {current sample size}
  117.     siSampleSizeAvailable        = 'ssav';                        {sample sizes available}
  118.     siStereoInputGain            = 'sgai';                        {stereo input gain}
  119.     siTwosComplementOnOff        = 'twos';                        {two's complement state}
  120.     siVoxRecordInfo                = 'voxr';                        {VOX record parameters}
  121.     siVoxStopInfo                = 'voxs';                        {VOX stop parameters}
  122.     siInitializeDriver            = 'init';                        {reserved for internal use only}
  123.     siCloseDriver                = 'clos';                        {reserved for internal use only}
  124.     siPauseRecording            = 'paus';                        {reserved for internal use only}
  125.     siUserInterruptProc            = 'user';                        {reserved for internal use only}
  126. {Qualities}
  127.     siCDQuality                    = 'cd  ';                        {44.1kHz, stereo, 16 bit}
  128.     siBestQuality                = 'best';                        {22kHz, mono, 8 bit}
  129.     siBetterQuality                = 'betr';                        {22kHz, mono, MACE 3:1}
  130.     siGoodQuality                = 'good';
  131.  
  132.     
  133. TYPE
  134.     SPBPtr = ^SPB;
  135.  
  136. {user procedures called by sound input routines}
  137.     {
  138.         SIInterruptProcPtr uses register based parameters on the 68k and cannot
  139.         be written in or called from a high-level language without the help of
  140.         mixed mode or assembly glue.
  141.  
  142.         In:
  143.          => inParamPtr      A0.L
  144.          => dataBuffer      A1.L
  145.          => peakAmplitude    D0.W
  146.          => sampleSize      D1.L
  147.     }
  148.     SIInterruptProcPtr = Register68kProcPtr;  { register PROCEDURE SIInterrupt(inParamPtr: SPBPtr; dataBuffer: Ptr; peakAmplitude: INTEGER; sampleSize: LONGINT); }
  149.     SICompletionProcPtr = ProcPtr;  { PROCEDURE SICompletion(inParamPtr: SPBPtr); }
  150.     SIInterruptUPP = UniversalProcPtr;
  151.     SICompletionUPP = UniversalProcPtr;
  152.  
  153.     SPB = RECORD
  154.         inRefNum:                LONGINT;                                {reference number of sound input device}
  155.         count:                    LONGINT;                                {number of bytes to record}
  156.         milliseconds:            LONGINT;                                {number of milliseconds to record}
  157.         bufferLength:            LONGINT;                                {length of buffer in bytes}
  158.         bufferPtr:                Ptr;                                    {buffer to store sound data in}
  159.         completionRoutine:        SICompletionUPP;                        {completion routine}
  160.         interruptRoutine:        SIInterruptUPP;                            {interrupt routine}
  161.         userLong:                LONGINT;                                {user-defined field}
  162.         error:                    OSErr;                                    {error}
  163.         unused1:                LONGINT;                                {reserved - must be zero}
  164.     END;
  165.  
  166.  
  167. FUNCTION SPBVersion: NumVersion;
  168.     {$IFC NOT GENERATINGCFM}
  169.     INLINE $203C, $0000, $0014, $A800;
  170.     {$ENDC}
  171. FUNCTION SndRecord(filterProc: ModalFilterUPP; corner: Point; quality: OSType; VAR sndHandle: SndListHandle): OSErr;
  172.     {$IFC NOT GENERATINGCFM}
  173.     INLINE $203C, $0804, $0014, $A800;
  174.     {$ENDC}
  175. FUNCTION SndRecordToFile(filterProc: ModalFilterUPP; corner: Point; quality: OSType; fRefNum: INTEGER): OSErr;
  176.     {$IFC NOT GENERATINGCFM}
  177.     INLINE $203C, $0708, $0014, $A800;
  178.     {$ENDC}
  179. FUNCTION SPBSignInDevice(deviceRefNum: INTEGER; deviceName: ConstStr255Param): OSErr;
  180.     {$IFC NOT GENERATINGCFM}
  181.     INLINE $203C, $030C, $0014, $A800;
  182.     {$ENDC}
  183. FUNCTION SPBSignOutDevice(deviceRefNum: INTEGER): OSErr;
  184.     {$IFC NOT GENERATINGCFM}
  185.     INLINE $203C, $0110, $0014, $A800;
  186.     {$ENDC}
  187. FUNCTION SPBGetIndexedDevice(count: INTEGER; VAR deviceName: Str255; VAR deviceIconHandle: Handle): OSErr;
  188.     {$IFC NOT GENERATINGCFM}
  189.     INLINE $203C, $0514, $0014, $A800;
  190.     {$ENDC}
  191. FUNCTION SPBOpenDevice(deviceName: ConstStr255Param; permission: INTEGER; VAR inRefNum: LONGINT): OSErr;
  192.     {$IFC NOT GENERATINGCFM}
  193.     INLINE $203C, $0518, $0014, $A800;
  194.     {$ENDC}
  195. FUNCTION SPBCloseDevice(inRefNum: LONGINT): OSErr;
  196.     {$IFC NOT GENERATINGCFM}
  197.     INLINE $203C, $021C, $0014, $A800;
  198.     {$ENDC}
  199. FUNCTION SPBRecord(inParamPtr: SPBPtr; asynchFlag: BOOLEAN): OSErr;
  200.     {$IFC NOT GENERATINGCFM}
  201.     INLINE $203C, $0320, $0014, $A800;
  202.     {$ENDC}
  203. FUNCTION SPBRecordToFile(fRefNum: INTEGER; inParamPtr: SPBPtr; asynchFlag: BOOLEAN): OSErr;
  204.     {$IFC NOT GENERATINGCFM}
  205.     INLINE $203C, $0424, $0014, $A800;
  206.     {$ENDC}
  207. FUNCTION SPBPauseRecording(inRefNum: LONGINT): OSErr;
  208.     {$IFC NOT GENERATINGCFM}
  209.     INLINE $203C, $0228, $0014, $A800;
  210.     {$ENDC}
  211. FUNCTION SPBResumeRecording(inRefNum: LONGINT): OSErr;
  212.     {$IFC NOT GENERATINGCFM}
  213.     INLINE $203C, $022C, $0014, $A800;
  214.     {$ENDC}
  215. FUNCTION SPBStopRecording(inRefNum: LONGINT): OSErr;
  216.     {$IFC NOT GENERATINGCFM}
  217.     INLINE $203C, $0230, $0014, $A800;
  218.     {$ENDC}
  219. FUNCTION SPBGetRecordingStatus(inRefNum: LONGINT; VAR recordingStatus: INTEGER; VAR meterLevel: INTEGER; VAR totalSamplesToRecord: LONGINT; VAR numberOfSamplesRecorded: LONGINT; VAR totalMsecsToRecord: LONGINT; VAR numberOfMsecsRecorded: LONGINT): OSErr;
  220.     {$IFC NOT GENERATINGCFM}
  221.     INLINE $203C, $0E34, $0014, $A800;
  222.     {$ENDC}
  223. FUNCTION SPBGetDeviceInfo(inRefNum: LONGINT; infoType: OSType; infoData: UNIV Ptr): OSErr;
  224.     {$IFC NOT GENERATINGCFM}
  225.     INLINE $203C, $0638, $0014, $A800;
  226.     {$ENDC}
  227. FUNCTION SPBSetDeviceInfo(inRefNum: LONGINT; infoType: OSType; infoData: UNIV Ptr): OSErr;
  228.     {$IFC NOT GENERATINGCFM}
  229.     INLINE $203C, $063C, $0014, $A800;
  230.     {$ENDC}
  231. FUNCTION SPBMillisecondsToBytes(inRefNum: LONGINT; VAR milliseconds: LONGINT): OSErr;
  232.     {$IFC NOT GENERATINGCFM}
  233.     INLINE $203C, $0440, $0014, $A800;
  234.     {$ENDC}
  235. FUNCTION SPBBytesToMilliseconds(inRefNum: LONGINT; VAR byteCount: LONGINT): OSErr;
  236.     {$IFC NOT GENERATINGCFM}
  237.     INLINE $203C, $0444, $0014, $A800;
  238.     {$ENDC}
  239. FUNCTION SetupSndHeader(sndHandle: SndListHandle; numChannels: INTEGER; sampleRate: UnsignedFixed; sampleSize: INTEGER; compressionType: OSType; baseNote: INTEGER; numBytes: LONGINT; VAR headerLen: INTEGER): OSErr;
  240.     {$IFC NOT GENERATINGCFM}
  241.     INLINE $203C, $0D48, $0014, $A800;
  242.     {$ENDC}
  243. FUNCTION SetupAIFFHeader(fRefNum: INTEGER; numChannels: INTEGER; sampleRate: UnsignedFixed; sampleSize: INTEGER; compressionType: OSType; numBytes: LONGINT; numFrames: LONGINT): OSErr;
  244.     {$IFC NOT GENERATINGCFM}
  245.     INLINE $203C, $0B4C, $0014, $A800;
  246.     {$ENDC}
  247. CONST
  248.     uppSIInterruptProcInfo = $1C579802; { Register PROCEDURE (4 bytes in A0, 4 bytes in A1, 2 bytes in D0, 4 bytes in D1); }
  249.     uppSICompletionProcInfo = $000000C0; { PROCEDURE (4 byte param); }
  250.  
  251. FUNCTION NewSIInterruptProc(userRoutine: SIInterruptProcPtr): SIInterruptUPP;
  252.     {$IFC NOT GENERATINGCFM }
  253.     INLINE $2E9F;
  254.     {$ENDC}
  255.  
  256. FUNCTION NewSICompletionProc(userRoutine: SICompletionProcPtr): SICompletionUPP;
  257.     {$IFC NOT GENERATINGCFM }
  258.     INLINE $2E9F;
  259.     {$ENDC}
  260.  
  261. PROCEDURE CallSIInterruptProc(inParamPtr: SPBPtr; dataBuffer: Ptr; peakAmplitude: INTEGER; sampleSize: LONGINT; userRoutine: SIInterruptUPP);
  262.     {$IFC NOT GENERATINGCFM}
  263.     {To be implemented:  Glue to move parameters into registers.}
  264.     {$ENDC}
  265.  
  266. PROCEDURE CallSICompletionProc(inParamPtr: SPBPtr; userRoutine: SICompletionUPP);
  267.     {$IFC NOT GENERATINGCFM}
  268.     INLINE $205F, $4E90;
  269.     {$ENDC}
  270.  
  271. {$ALIGN RESET}
  272. {$POP}
  273.  
  274. {$SETC UsingIncludes := SoundInputIncludes}
  275.  
  276. {$ENDC} {__SOUNDINPUT__}
  277.  
  278. {$IFC NOT UsingIncludes}
  279.  END.
  280. {$ENDC}
  281.